using System;
using System.Collections.Generic;
using System.Text;

namespace Data.Abstract
{
    public abstract class BaseObject<T> where T: BaseSimple,new()
    {
        
        protected object _Dal;
        protected object Dal
        {
            get { return _Dal; }
            set { _Dal = value; }
        }

		public BaseObject(){}
        
        public BaseObject<T> Load(T Simple)
        {
            this._Simple = Simple;
            return this;
        }
        public abstract void Insert();
        public abstract void Update();
        public abstract void Delete();

		protected T _Simple;
        public T Simple
        {
            get { return _Simple; }
            set { _Simple = value; }
        }

        public bool IsLoad() { return this.Simple != null; }
        public bool IsLoadSucceded() { return this.Simple != null && this.Simple.Id != 0; }

        protected void CheckLoaded()
        {
            if (this.Simple == null)
            {
                throw new ApplicationException(typeof(T).Name + " not loaded. Load the object to Operate.");
            }
        }
    }
}
